class Solution {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] ran = new int[26];
        for (int i = 0; i < ransomNote.length(); i++) {
            ran[ransomNote.charAt(i) - 'a'] ++;
        }

        for (int i = 0; i < magazine.length(); i++) {
            if (ran[magazine.charAt(i) - 'a'] > 0){
                ran[magazine.charAt(i) - 'a'] --;
            }
        }

        for (int i : ran) {
            if (i > 0) return false;
        }
        return true;
    }
}